package gui;

import java.awt.Color;
import javax.swing.JPanel;
import data.cell;

public class mazePanel extends JPanel
{
	/**
	 * 
	 */
	private static final long serialVersionUID = -4700939989196503646L;
	cell[][] maze;
	int x = 0;
	int y = 0;
	
	public mazePanel(cell[][] maze)
	{
		this.maze = maze;
		this.setSize(640,680);
		repaint();
		this.setBackground(Color.BLACK);
		this.setVisible(true);
	}
	
	protected void paintComponent(java.awt.Graphics g) 
	{
        super.paintComponent(g);
		g.setColor(Color.red);
		
		x=0;
		for(int i = 0; i<64;i++)
		{
			g.setColor(Color.red);
			y = 0;
			for(int j = 0; j< 64; j++)
			{
				//Muren tekenen
				g.setColor(Color.red);
				
				if(maze[i][j].isWallNorth())
				{
					//g.setColor(Color.blue);
					g.drawLine(x, y, x+10, y);
				}
				if(maze[i][j].isWallSouth())
				{
					//g.setColor(Color.white);
					g.drawLine(x, y+10, x+10, y+10);
				}
				if(maze[i][j].isWallEast())
				{
					//g.setColor(Color.yellow);
					g.drawLine(x+10,y,x+10,y+10);
				}
				if(maze[i][j].isWallWest())
				{
					//g.setColor(Color.green);
					g.drawLine(x,y,x,y+10);
				}
				
				//Start aangeven
				if(maze[i][j].isStart())
				{
					g.setColor(Color.green);
					g.fillRect(x, y, 10, 10);
				}
				
				//Einde aangeven
				if(maze[i][j].isExit())
				{
					g.setColor(Color.red);
					g.fillRect(x,y,10,10);
				}
				y = y+10;
				
				//Path aangeven
				g.setColor(Color.yellow);
				if(maze[i][j].isPathEast())
				{
					g.drawLine(x+5,y-5,x+10,y-5);
				}
				if(maze[i][j].isPathWest())
				{
					g.drawLine(x+5,y-5,x,y-5);
				}
				if(maze[i][j].isPathNorth())
				{
					g.drawLine(x+5,y-5,x+5,y-10);
				}
				if(maze[i][j].isPathSouth())
				{
					g.drawLine(x+5,y-5,x+5,y);
				}
				
				g.setColor(Color.gray);
				if(maze[i][j].isBacktrackEast())
				{
					g.drawLine(x+5,y-5,x+10,y-5);
				}
				if(maze[i][j].isBacktrackWest())
				{
					g.drawLine(x+5,y-5,x,y-5);
				}
				if(maze[i][j].isBacktrackNorth())
				{
					g.drawLine(x+5,y-5,x+5,y-10);
				}
				if(maze[i][j].isBacktrackSouth())
				{
					g.drawLine(x+5,y-5,x+5,y);
				}
			}
			x = x+10;
		}
	}
}
